package edu.se.jai.openfeignapi.feign;

import edu.se.jai.openfeignapi.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Game Service Feign API 接口定义
 *
 * 定义游戏服务的REST API契约
 * - 服务提供方（game-service）实现此接口
 * - 服务消费方（websocket-gateway）通过此 Feign 客户端调用
 */
@FeignClient(name = "game-service", path = "/api/game")
public interface GameServiceFeignApi {

	// ==================== 玩家管理接口 ====================

	@GetMapping("/player/register")
	Result<String> registerPlayer(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("playerName") String playerName);

	@PostMapping("/player/clear")
	Result<String> clearPlayer(@RequestParam("sessionId") String sessionId);

	// ==================== 房间管理接口 ====================

	@GetMapping("/room/create")
	Result<GameRoomDto> createRoom(@RequestParam("sessionId") String sessionId);

	@GetMapping("/room/join")
	Result<GameRoomDto> joinRoom(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("roomId") String roomId);

	@GetMapping("/room/leave")
	Result<GameRoomDto> leaveRoom(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("roomId") String roomId);

	@GetMapping("/room/dissolve")
	Result<GameRoomDto> dissolveRoom(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("roomId") String roomId);

	@GetMapping("/room/list")
	Result<List<GameRoomDto>> getAllRooms();

	@GetMapping("/room/bySession/{sessionId}")
	Result<GameRoomDto> getRoomBySessionId(@PathVariable("sessionId") String sessionId);

	@GetMapping("/room/{roomId}")
	Result<GameRoomDto> getRoomById(@PathVariable("roomId") String roomId);

	// ==================== 游戏逻辑接口 ====================

	@GetMapping("/game/start")
	Result<GameRoomDto> startGame(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("roomId") String roomId);

	@GetMapping("/game/stop")
	Result<GameRoomDto> stopGame(
			@RequestParam("sessionId") String sessionId,
			@RequestParam("roomId") String roomId);

	@PostMapping("/game/guess")
	Result<GuessResultDto> makeGuess(@RequestBody GuessDto request);
}
